package cn.langpy.disroute.core;



import java.util.concurrent.*;

/**
 * Chang Zhang
 */
public class RoutePool {
    public static ThreadPoolExecutor getPool() {
        return SingletonHolder.threadPoolTaskExecutor;

    }

    public static boolean isFree(){
        return SingletonHolder.threadPoolTaskExecutor.getActiveCount()==0;
    }

    public static void closePool(){
        SingletonHolder.threadPoolTaskExecutor.shutdown();
    }
    private static class SingletonHolder {
        private static final ThreadPoolExecutor threadPoolTaskExecutor = new ThreadPoolExecutor(0, 5000,60L, TimeUnit.SECONDS,new SynchronousQueue<Runnable>());

    }
}
